{extend name='common/content' /}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <button data-modal='{:url("$classuri/add")}' data-title="添加配置" class='layui-btn layui-btn-small'><i
            class='fa fa-plus'></i> 添加配置
    </button>
    <!--<button data-update data-field='delete' data-action='{:url("$classuri/del")}'
            class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除配置
    </button>-->
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">

    <div class="row">
        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="name" value="{$Think.get.name|default=''}" placeholder="名称"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="title" value="{$Think.get.title|default=''}" placeholder="标题"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
            </div>
        </div>
    </div>
</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="" method="POST">
    <input type="hidden" value="resort" name="action"/>
    <div class="layui-tab layui-tab-card">
        <ul class="layui-tab-title">
            {foreach $tab_list as $key=>$tab}
            <li {if $key eq 0}class="layui-this"{/if}>{$tab.title}</li>
            {/foreach}
        </ul>
        <div class="layui-tab-content" style="height: auto;">
            {foreach $tab_list as $key=>$tab}
            <div class="layui-tab-item {if $key eq 0}layui-show{/if}">
                <div class="layui-form">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th>
                                <input data-none-auto="" data-check-target='.list-check-box' lay-skin="primary" lay-filter="allChoose" type="checkbox">
                            </th>
                            <th class='list-table-sort-td'>
                                <button type="submit" class="layui-btn layui-btn-normal layui-btn-mini">排 序</button>
                            </th>
                            <th class='text-center'>名称</th>
                            <th class='text-center'>标题</th>
                            <th class='text-center'>状态</th>
                            <th class='text-center'>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $tab['list'] as $lkey=>$vo}
                        <tr>
                            <td>
                                <input class="list-check-box" value='{$vo.id}' lay-skin="primary" type="checkbox">
                            </td>
                            <td class='list-table-sort-td'>
                                <input name="_{$vo.id}" value="{$vo.sort}" class="list-sort-input"/>
                            </td>
                            <td class='text-center'>{$vo.name}</td>
                            <td class='text-center'>{$vo.title}</td>
                            <td class='text-center'>
                                {if $vo.status eq 0}
                                <span>已禁用</span>
                                {elseif $vo.status eq 1}
                                <span style="color:#090">使用中</span>
                                {/if}
                            </td>
                            <td class='text-center nowrap'>
                                <div class="layui-btn-group">
                                    {if $vo.status eq 1 and auth("$classuri/forbid")}
                                    <!--<button type="button" data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}' class="layui-btn layui-btn-primary layui-btn-small">禁用</button>-->
                                    {elseif auth("$classuri/resume")}
                                    <button type="button" data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}' class="layui-btn layui-btn-primary layui-btn-small">启用</button>
                                    {/if}

                                    {if auth("$classuri/edit")}
                                    <!--<button type="button" data-modal='{:url("$classuri/edit")}?id={$vo.id}' class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i></button>-->
                                    {/if}

                                    {if auth("$classuri/del")}
                                    <!--<button type="button" data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}' class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i></button>-->
                                    {/if}
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
                {if isset($page)}<p>{$page}</p>{/if}
            </div>
            {/foreach}
        </div>
    </div>
</form>
<script>window.form.render();</script>
<script>
    layui.use('form', function(){
        var $ = layui.jquery, form = layui.form;

        //全选
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
    });

    layui.use('element', function(){
        var $ = layui.jquery
            ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
    });
</script>
{/block}